package java_012_zuoye07;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Arrays;

public class java05 {
	public static void main(String[] args) throws IOException {
		File file = new File("a.txt");
		FileOutputStream fos = new FileOutputStream(file);
		byte[] b="2-1-9-4-7-8".getBytes();
		fos.write(b);
		FileInputStream fis = new FileInputStream(file);
		byte[] bytes = new byte[2024];
		int len;
		String str = null;
		while((len=fis.read(bytes))!=-1){
			str = new String(bytes,0,len);
		}
		Integer[] arr = Arrays.stream(str.toString()
				.split("-"))
				.map(Integer::parseInt).
				sorted()
				.toArray(Integer[]::new);
		String s = Arrays.toString(arr).replace(",", "-");
		byte[] b1 = s.getBytes();
		fos.write("\n".getBytes());
		fos.write(b1);
		fis.close();
		fos.close();
	}
}
